package operation;

import book.Book;
import book.BookList;

public class FindOperation implements IOperation{

    @Override
    public void work(BookList bookList) {

        System.out.println("查找图书");
        System.out.println("请输入你要查找书的名称");
        String name = scanner.next();

        //遍历BookList数组
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);
            //看这本书是否一样
            if(book.getName().equals(name)){
                System.out.println("查找到了这本书");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有找到这本书");
    }
}
